#!/bin/bash

outputType=png

dotFiles=("application-lifetime" "modules-package" "url-priority")

function dot_compile() {
    dot -T $outputType -s $1.dot -o $1.$outputType 1>/dev/null
}

i=0
while [[ $i < ${#dotFiles[@]} ]]; do
    if [[ ! -f "${dotFiles[$i]}.$outputType" || "${dotFiles[$i]}.dot" -nt "${dotFiles[$i]}.$outputType" ]]; then
        echo "Compiling ${dotFiles[$i]}.dot..."
        dot_compile ${dotFiles[$i]}
    fi
    ((i++))
done

echo "Compilation complete."
